<?php


namespace app\index\controller;

use think\Controller;

class Home extends Controller {

    # 获取下拉菜单列表
    public function GetDropList(){
        $classArr = db("class")->where("is_del", 0)->select();
        $gradeArr = db("grade")->where("is_del", 0)->select();
        $languageArr = db("language")->where("is_del", 0)->select();
        $class = []; $grade = []; $language = [];

        if(!empty($classArr)){
            foreach ($classArr as $value){
                $class[] = [
                    "id" => (int)$value["cid"],
                    "name" => $value["name"]
                ];
            }
        }
        if(!empty($gradeArr)){
            foreach ($gradeArr as $value){
                $grade[] = [
                    "id" => (int)$value["gid"],
                    "name" => $value["name"]
                ];
            }
        }
        if(!empty($languageArr)){
            foreach ($languageArr as $value){
                $language[] = [
                    "id" => (int)$value["lid"],
                    "name" => $value["name"]
                ];
            }
        }

        $data = [
            "class" => $class,
            "grade" => $grade,
            "language" => $language
        ];

        Code(200, false, $data);
    }

}